package com.qf.ssm.service.Impl;

import com.qf.ssm.ex.ServiceException;
import com.qf.ssm.utils.ResponseCode;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.qf.ssm.entity.Commodity;
import com.qf.ssm.mapper.CommodityMapper;
import com.qf.ssm.service.CommodityService;

import java.util.List;

@Service
public class CommodityServiceImpl implements CommodityService{

    @Resource
    private CommodityMapper commodityMapper;

    @Override
    public int deleteByPrimaryKey(Integer cId) {
        return commodityMapper.deleteByPrimaryKey(cId);
    }

    @Override
    public int insert(Commodity record) {
        return commodityMapper.insert(record);
    }

    @Override
    public int insertSelective(Commodity record) {
        return commodityMapper.insertSelective(record);
    }

    @Override
    public Commodity selectByPrimaryKey(Integer cId) {
        return commodityMapper.selectByPrimaryKey(cId);
    }

    @Override
    public int updateByPrimaryKeySelective(Commodity record) {
        return commodityMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Commodity record) {
        return commodityMapper.updateByPrimaryKey(record);
    }

    @Override
    public int updateState(int id) {
        return commodityMapper.updateState(id);
    }

    @Override
    public int updateStateList(List<Integer> ids) {
        return commodityMapper.updateStateList(ids);
    }

    @Override
    public int deleteList(List<Integer> ids) {
        return commodityMapper.deleteList(ids);
    }

    @Override
    public int setNewCommodity(Commodity commodity) {
        return commodityMapper.setNewCommodity(commodity);
    }

    @Override
    public List<Commodity> queryGoods(String goodsName, String goodsType) {
        try{
            return commodityMapper.selectGoodsInfo(goodsName, goodsType);
        }catch (Exception e){
            throw new ServiceException(ResponseCode.BRAND_SELECT);
        }
    }


}
